﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.IRepository;
using Model;
using Lib.Query.NHibernate;
using NHibernate;
using Lib.Query;

namespace DataAccess.NHibernate
{
    public class PolicyRepository : IPolicyRepository
    {        
        public IList<T> FindBy<T>(IReadLiteQuery query) where T:Policy
        {
            ICriteria criteriaQuery = NHSessionFactory.Context.CreateCriteria(typeof(T));
            criteriaQuery = query.Translate<T>(criteriaQuery);
            return criteriaQuery.List<T>();
        }        
    }
}
